package com.qire.manhua.activity.intercept;

import android.content.Context;

import com.qire.antscore.annotation.InterceptorMapping;
import com.qire.antsrouter.card.Postcard;
import com.qire.antsrouter.intercept.InterceptRules;
import com.qire.antsrouter.intercept.Interceptor;
import com.qire.common.constant.Navigation;
import com.qire.manhua.activity.helper.LoginRouter;

/**
 * 未登录拦截器，对于 UserGroup 组别的页面都需要登录后才能进入，
 * 如果进入这些页面时是未登录状态拦截器会停止跳转页面，并打开登录页
 * 全局单例。
 */
@InterceptorMapping(group = Navigation.Group.UserGroup)
public class NotLoginIntercept implements InterceptRules {

    @Override
    public void init(Context context) { }

    @Override
    public void process(Postcard postcard, Interceptor interceptor) {
//        if(!UserEntity.self.isLogin()) {
        if(LoginRouter.ROUTER.checkLoginRouteIfNeed()) {
            interceptor.onInterrupt("未登录");
//            AntsRouter.ROUTER.buildCard(Navigation.Page.LoginGuidePage).navigation();
        } else {
            interceptor.onNext();
        }
    }
}
